class Solution {
    public int lengthOfLongestSubstring(String s) {
        if(null == s) {
            System.out.println("null");
            return 0;
        }
        if(1 == s.length()) {
            return 1;
        }
        int len = s.length();
        Map<Character,Integer> hashmap = new HashMap<Character,Integer>();
        int i = 0;
        int left = 0;
        int max = 0;
        for(i =0 ;i<len;i++) {
            
            if(hashmap.containsKey(s.charAt(i))) {
                left = Math.max(left,hashmap.get(s.charAt(i))+1);
            }
            hashmap.put(s.charAt(i),i);
            max = Math.max(max,i-left+1);
        }
        return max;
    }
}